Page({
  data: {
    notes: [],
  },
  onLoad: function () {
    this.loadNotes();
  },
  onShow: function () {
    this.loadNotes();
  },
  loadNotes: function () {
    const notes = wx.getStorageSync('notes') || [];
    this.setData({ notes });
  },
  addNote: function () {
    wx.navigateTo({
      url: '/pages/add/add',
    });
  },
  viewNote: function (e) {
    const id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: `/pages/note/note?id=${id}`,
    });
  },
});